package pers.cz.javacvdemo.video;

import lombok.Data;

/**
 * @version 1.0
 * @description: 分辨率
 * @author: ChengZhi 0336
 * @create: 2025-08-15 16:20
 **/
@Data
public class Resolution {

	private int width;
	private int height;
	private String suffix;
	private int bitrate;

	public Resolution(int width, int height, String suffix) {
		this.width = width;
		this.height = height;
		this.suffix = suffix;
		this.bitrate = calculateBitrate(width, height);
	}

	private int calculateBitrate(int width, int height) {
		// 根据分辨率计算推荐码率
		int pixels = width * height;
		if (pixels >= 1920 * 1080) return 5000;      // 1080p: 5Mbps
		else if (pixels >= 1280 * 720) return 3000;  // 720p: 3Mbps
		else if (pixels >= 854 * 480) return 1500;   // 480p: 1.5Mbps
		else return 800;                             // 360p: 800kbps
	}

	public String getResolutionString() {
		return width + "x" + height;
	}

}
